package ThreadTest;

public class Base {

    public static void main(String[] args) {
//        System.out.println("Thread.getAllStackTraces() = " + Thread.getAllStackTraces());
//        Thread t = new Thread();
//        Runnable r1 = () ->{
//            Runnable r2 = () ->{
//                System.out.println("r2");
//            };
//            r2.run();
//            System.out.println("r1");
//        };
//        r1.run();
        r3 r3 = new r3();
        r3.run();

//        MyThread myThread0 = new MyThread("group1");
//        MyThread myThread2 = new MyThread("group1","myThread2");
//        myThread1.start();
//        myThread2.start();
//        System.out.println("myThread1.getThreadGroup() = " + myThread1.getThreadGroup());
//        System.out.println("myThread2.getThreadGroup() = " + myThread2.getThreadGroup());
//        System.out.println("myThread1.getName() = " + myThread1.getName());
//        System.out.println("myThread2.getName() = " + myThread2.getName());

//        MyThread1 myThread1 = new MyThread1();
//        myThread1.start();
//        System.out.println(myThread1.currentThread().getThreadGroup().getName());
        new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(i);
                try {
                    System.out.println("Thread.currentThread().isAlive() = " + Thread.currentThread().isAlive());
                    Thread.currentThread().sleep(1000);
                    System.out.println("Thread.currentThread().isAlive() = " + Thread.currentThread().isAlive());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getThreadGroup().getName());
        }).start();



    }
}
class r3 implements Runnable{

    @Override
    public void run() {
        System.out.println("r3");
    }
}

class MyThread extends Thread{

    public MyThread(String group1){
        super(group1);
    };
    @Override
    public void run() {
        System.out.println("myThread");
    }
}
class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println("myThread1");
    }
}
class MyThread2 extends Thread{
    @Override
    public void run() {
        System.out.println("myThread2");
    }
}
